<?php
# -*- coding: utf-8 -*-
/**
 * 缓存目录位置
 */
FLEA::setAppInf('internalCacheDir', ROOT_DIR . '/cache/runtime');

/**
 * 模式配置文件
 */
$deploy = defined('DEPLOY_MODE') && DEPLOY_MODE;
if ( $deploy ) {
	$lifetime = 86400; //一天
} else {
	$lifetime = 0;
}

/**
 * 返回配置
 */
$cacheid = 'config.' . ($this->_app ? $this->_app . '.' : '') . ($deploy ? 'deploy' : 'development');
$_config = FLEA::getCache($cacheid, $lifetime, true, true);
if (is_array($_config)) { return $_config; }

if ( $deploy ) {
    $mode = require 'deploy.php';
} else {
	$mode = require 'devel.php';
}

$path = array(
    'siteUrl' => 'http://www.myblog.com',
    'blogUrl' => 'http://lite.myblog.com',
    'uploadDir' => ROOT_DIR . '/uploads',
    'uploadPath' => '/uploads/'
);

/**
 * 数据库配置文件
 */
$database = array (
        'dbDSN' => array(
          'driver' => 'mysql',
          'host' => 'localhost',
          'login' => 'root',
          'password' => 123456,
          'database' => 'moblog_lite_db',
          'port' => 3306,
          'charset' => 'utf8'
        ),
        'dbTablePrefix' => 'mo_'
);

/**
 * 环境配置文件
 */
$environment = array (
    'urlLowerChar' => true, //将URL中的参数强制转换为小写字母
    'internalCacheDir' => ROOT_DIR . '/cache/runtime', //缓存目录位置
    'logFileDir' => ROOT_DIR . '/cache/log', //日志目录位置
    'webControlsExtendsDir' => ROOT_DIR . '/sysadm/apps/' . $this->_app . '/webcontrol', //Web控件目录位置
    'controllerAccessor' => 'ctl', //控制器参数名
    'actionAccessor' => 'act', //控制器方法参数名
    'urlAlwaysUseAccessor' => false,
    'urlLowerChar' => true,
    // 默认主题
    'defaultTheme' => 'default',
    //日志文件名称
    'logFilename' => $this->_app . '_access.log',
    //FckEditor目录位置
    'fckEditorDir' => ROOT_DIR . '/sysadm/editor/fckeditor'
);

/**
 * 模板配置文件
 */

$themeDir = $this->_app;
if ($themeDir=='blog') {
    $themeDir = FLEA::getAppInf('defaultTheme');
}

$themes = array (
    'THEME_DIR' => $path['blogUrl'] . '/themes/' . $themeDir,
    'view' => 'FLEA_View_Smarty',
    'viewConfig' => array(
        'smartyDir' => ROOT_DIR . '/sysadm/libs/Smarty',
        'template_dir' => ROOT_DIR . '/themes/' . $themeDir,
        'compile_dir' => ROOT_DIR . '/cache/tmp_c',
        'left_delimiter' => '{{',
        'right_delimiter' => '}}'
    )
);

$_config = array_merge( $database, $environment, $mode, $themes, $path );
FLEA::writeCache($cacheid, $_config, true);
unset($database, $environment, $mode, $themes, $cacheid, $path);
return $_config;
